The visualised data graphs, obtained from the NLP sentiment analysis, needed to transformed, onto a map of Australia, so to compare and contrast the difference between each of the cities and states. The first map showcases the cities only whereas the second map showcases only the states.
import pandas as pd
import folium
from folium import IFrame, plugins
from collections import Counter
import json
import base64
state_geo = 'au-states.geojson'
total_dist = Counter(state_data['State'])
m = folium.Map(location=[-33.8, 151.2], zoom_start=3)
folium.Choropleth(
geo_data=state_geo,
name="choropleth",
data=total_dist,
columns=["State", "DistilBERT_Score"],
key_on="feature.id",
fill_color="YlGnBu",
fill_opacity=0.7,
line_opacity=0.2,
legend_name="Distribution of Twitter Tweeets",
).add_to(m)
folium.LayerControl().add_to(m)
folium.plugins.MiniMap().add_to(m)
# Melbourne
encoded = base64.b64encode(open('Images/Mel.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
mel_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-37.8136, 144.9631],
radius=50000,
icon=folium.Icon(icon='pin'),
popup=mel_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Sydney
encoded = base64.b64encode(open('Images/Syd.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
syd_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-33.8688, 151.2093],
radius=50000,
popup=syd_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Brisbane
encoded = base64.b64encode(open('Images/Bri.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
bri_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-27.4705, 153.0260],
radius=50000,
popup=bri_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Perth
encoded = base64.b64encode(open('Images/Per.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
per_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-31.9523, 115.8613],
radius=50000,
popup=per_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Adelaide
encoded = base64.b64encode(open('Images/Ade.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
ade_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-34.9285, 138.6007],
radius=50000,
popup=ade_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Gold Coast
encoded = base64.b64encode(open('Images/Golcoa.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
golcoa_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-28.0167, 153.4000],
radius=50000,
popup=golcoa_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Newcastle
encoded = base64.b64encode(open('Images/New.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
new_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-32.93, 151.75],
radius=50000,
popup=new_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Canberra
encoded = base64.b64encode(open('Images/Can.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
Can_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-35.2809, 149.1300],
radius=50000,
popup=Can_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Sunshine Coast
encoded = base64.b64encode(open('Images/Suncoa.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
suncoa_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-26.6500, 153.0667],
radius=50000,
popup=suncoa_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Central Coast
encoded = base64.b64encode(open('Images/Cencoa.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
cencoa_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-33.3208, 151.2336],
radius=50000,
popup=cencoa_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Wollongong
encoded = base64.b64encode(open('Images/Wol.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
wol_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-34.4248, 150.8931],
radius=50000,
popup=wol_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Geelong
encoded = base64.b64encode(open('Images/Gee.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
gee_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-38.1499, 144.3617],
radius=50000,
popup=gee_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Hobart
encoded = base64.b64encode(open('Images/Hob.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
hob_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-42.8826, 147.3257],
radius=50000,
popup=hob_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Townsville
encoded = base64.b64encode(open('Images/Tow.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
tow_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-19.2590, 146.8169],
radius=50000,
popup=tow_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Cairns
encoded = base64.b64encode(open('Images/Cai.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
cai_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-16.9203, 145.7710],
radius=50000,
popup=cai_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Toowoomba
encoded = base64.b64encode(open('Images/Too.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
too_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-27.5598, 151.9507],
radius=50000,
popup=too_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Darwin
encoded = base64.b64encode(open('Images/Dar.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
dar_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-12.4637, 130.8444],
radius=50000,
popup=dar_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Ballarat
encoded = base64.b64encode(open('Images/Bal.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
bal_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-37.5622, 143.8503],
radius=50000,
popup=bal_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
# Bendigo
encoded = base64.b64encode(open('Images/Ben.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
ben_popup = folium.Popup(iframe, max_width=500)
folium.Circle(
location=[-36.7570, 144.2794],
radius=50000,
popup=ben_popup,
color='#E980CF',
fill=True,
fill_color='#E980CF',
fill_opacity=0.1
).add_to(m)
m
import pandas as pd
import folium
from folium import IFrame, plugins
from collections import Counter
import json
import base64
state_geo = 'au-states.geojson'
total_dist = Counter(state_data['State'])
m = folium.Map(location=[-33.8, 151.2], zoom_start=3)
folium.Choropleth(
geo_data=state_geo,
name="choropleth",
data=total_dist,
columns=["State", "DistilBERT_Score"],
key_on="feature.id",
fill_color="YlOrRd",
fill_opacity=0.7,
line_opacity=0.2,
legend_name="Distribution of Twitter Tweeets",
).add_to(m)
folium.LayerControl().add_to(m)
folium.plugins.MiniMap().add_to(m)
# VIC
encoded = base64.b64encode(open('Images/VIC.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
vic_popup = folium.Popup(iframe, max_width=500)
folium.Marker(
location=[-36.967449, 144.525337],
icon=folium.Icon(icon='pin'),
popup=vic_popup,
).add_to(m)
# NSW
encoded = base64.b64encode(open('Images/NSW.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
nsw_popup = folium.Popup(iframe, max_width=500)
folium.Marker(
location=[-32.731841, 146.359764],
icon=folium.Icon(icon='pin'),
popup=nsw_popup,
).add_to(m)
# QLD
encoded = base64.b64encode(open('Images/QLD.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
qld_popup = folium.Popup(iframe, max_width=500)
folium.Marker(
location=[-22.71539, 144.688883],
icon=folium.Icon(icon='pin'),
popup=qld_popup,
).add_to(m)
# SA
encoded = base64.b64encode(open('Images/SA.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
sa_popup = folium.Popup(iframe, max_width=500)
folium.Marker(
location=[-29.726222, 135.543457],
icon=folium.Icon(icon='pin'),
popup=sa_popup,
).add_to(m)
# WA
encoded = base64.b64encode(open('Images/WA.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
wa_popup = folium.Popup(iframe, max_width=500)
folium.Marker(
location=[-25.522615, 122.056764],
icon=folium.Icon(icon='pin'),
popup=wa_popup,
).add_to(m)
# TAS
encoded = base64.b64encode(open('Images/TAS.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
tas_popup = folium.Popup(iframe, max_width=500)
folium.Marker(
location=[-42.065607, 146.669386],
icon=folium.Icon(icon='pin'),
popup=tas_popup,
).add_to(m)
# NT
encoded = base64.b64encode(open('Images/NT.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
nt_popup = folium.Popup(iframe, max_width=500)
folium.Marker(
location=[-19.352611, 133.431428],
icon=folium.Icon(icon='pin'),
popup=nt_popup,
).add_to(m)
# ACT
encoded = base64.b64encode(open('Images/ACT.png', 'rb').read())
html = '<img src="data:image/png;base64,{}">'.format
iframe = IFrame(html(encoded.decode('UTF-8')), width=500, height=300)
act_popup = folium.Popup(iframe, max_width=500)
folium.Marker(
location=[-35.496456, 148.938881],
icon=folium.Icon(icon='pin'),
popup=act_popup,
).add_to(m)
m